package com.ssh.service.impl;

import com.ssh.entity.Person;
import com.ssh.repository.PersonRepository;
import com.ssh.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PersonServiceImpl implements PersonService {
    @Autowired(required=true)
    PersonRepository personRepository;

    @Override
    public List<Person> getPersons(){
        return personRepository.findAll();
    }

    @Override
    public Long addPerson(){
        Person person = new Person();
        person.setUsername("XRog");
        person.setPhone("18381005946");
//        person.setRemark("this is XRog");
        return personRepository.save(person);
    }

    @Override
    public Person getPersonById(Long id) {
        return personRepository.get(id);
    }
}
